<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
include ("../../include/dbFunctions.php");
include ("../../include/image_slider.php");
include ("../../include/function.php");


if (isset($_SESSION['volunteer_id']) || isset($_SESSION['school_id'])) {

    if (isset($_SESSION['volunteer_id'])) {
        $volunteer_id = $_SESSION['volunteer_id'];
    }
    if (isset($_SESSION['school_id'])) {

        $volunteer_id = $_GET['id'];
    }


//get volunteer details
    $volunteer = "SELECT * FROM volunteer WHERE volunteer_id = $volunteer_id";
    $volunteer = executeSelectQuery($volunteer);
    $sponsor_id = $volunteer[0]['sponsor_id'];

// get sponsor
    $sponsor_name = "SELECT sponsor_name FROM sponsor WHERE sponsor_id = $sponsor_id ";
    $sponsor_name = executeSelectQuery($sponsor_name);

//get volunteer education level prefer
    $education = "SELECT p.education_id, e.education_name FROM education_preference p, education e  WHERE p.education_id = e.education_id AND p.volunteer_id = $volunteer_id ";
    $education = executeSelectQuery($education);
// get volunteer location
    $location = "SELECT p.location_id, l.location_name FROM location_preference p, location l  WHERE p.location_id = l.location_id AND p.volunteer_id = $volunteer_id";
    $location = executeSelectQuery($location);

//select volunteer time slot
    $query = "SELECT p.time_id, t.time_name FROM time t, time_preference p  WHERE p.time_id = t.time_id AND p.volunteer_id = $volunteer_id";
    $time = executeSelectQuery($query);
}
?>

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css" title="currentStyle">
            @import "../../media/css/jqdialog.css";
        </style>
        <title>Junior Achievement Singapore</title>
        <link href="../../media/css/styles.css" rel="stylesheet" type="text/css" />


        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="../../media/js/jquery/image_slider.js"></script>
        <!-- Custom jquery scripts -->
        <script src="../../media/js/jquery/custom_jquery.js" type="text/javascript"></script>
        <script type="text/javascript" src="../../media/js/jqueryUI/jquery-ui-1.8.13.custom.js"></script>
        <script type="text/javascript" src="../../media/js/jquery/jqdialog.min.js"></script>
        <script type="text/javascript" src="../../media/js/jqueryUI/jquery.ui.dialog.js"></script>

    </head>
    <body>
        <script>
            var timeout    = 700;
            var closetimer = 0;
            var ddmenuitem = 0;

            function jsddm_open()
            {  jsddm_canceltimer();
                jsddm_close();
                ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

            function jsddm_close()
            {  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

            function jsddm_timer()
            {  closetimer = window.setTimeout(jsddm_close, timeout);}

            function jsddm_canceltimer()
            {  if(closetimer)
                {  window.clearTimeout(closetimer);
                    closetimer = null;}}

            $(document).ready(function()
            {  $('#navigation > li').bind('mouseover', jsddm_open)
                $('#navigation > li').bind('mouseout',  jsddm_timer)});

            document.onclick = jsddm_close;

        </script>
        <div id="container"><!--CONTAINER STARTS-->
            <div id="navigation">
                <li><a href="../../include/home/homepage.php">HOME</a></li>
                <li><a href="../../include/home/contact.php">CONTACT</a></li>
                <li><a href="http://ja.org.sg/">ABOUT JA SINGAPORE</a></li>
                <li><a href="http://jascheduling.lefora.com/">FEEDBACK</a></li>
                <li><a href="../../guide/guide_menu.php">HELP</a></li>

            </div>
            <div id="title"><!--TITLE STARTS-->
            </div><!--TITLE ENDS-->
            <div id="featured"><!--FEATURED AREA STARTS-->

                <div class="featured-image"><!--FEATURED IMAGE STARTS-->
                    <img alt="Featured Image" src="../../media/images/featured_image.png" />
                </div><!--FEATURED IMAGE ENDS-->
                <div class="featured-text"><!--FEATURED TEXT STARTS-->
                    <h2>Welcome to JA Singapore </h2>
                    <p>Junior Achievement programs help prepare young people for the real world by showing them how to generate wealth and effectively manage it, how to create jobs which make their communities more robust, and how to apply entrepreneurial thinking to the workplace. <a href="http://www.jaworldwide.org/">Read More... </a></p>
                </div><!--FEATURED TEXT ENDS-->
            </div><!--FEATURED AREA ENDS-->
            <?php
            custom_login();
            ?>
            <div id="left-content"><!--RIGHT CONTENT STARTS-->
                <div class="left-top"><!--RIGHT CONTENT BOX TOP-->
                </div><!--RIGHT CONTENT BOX TOP ENDS-->
                <div class="left-middle"><!--RIGHT CONTENT BOX MIDDLE-->
                    <?php
                    if (!isset($_SESSION['volunteer_id']) && !isset($_SESSION['school_id'])) {
                        echo "<br/><br/><br/><br/><br/><center><h3>You don't have permission to view this page<h3><br/>
                           Please login to access the page.</center><br/><br/><br/><br/><br/><br/><br/><br/>";
                    } else {
                        ?>
                    <h3>Personal Information</h3>
                    <br/>
                    <!-- print out volunteer details-->
                    <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                        <tr>
                            <th valign="top">My Salutation:  </th>
                            <td><?php echo $volunteer[0]['volunteer_salutation'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My First Name: </th>
                            <td><?php echo $volunteer[0]['volunteer_firstname'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Family Name: </th>
                            <td><?php echo $volunteer[0]['volunteer_surname'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Gender:  </th>
                            <td><?php echo $volunteer[0]['volunteer_gender'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Organization:  </th>
                            <td> <?php echo $sponsor_name[0]['sponsor_name'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Profession: </th>
                            <td><?php echo $volunteer[0]['volunteer_profession'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">Years Of Working: </th>
                            <td><?php echo $volunteer[0]['volunteer_experience'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Resume: </th>
                            <td><a href="../../admin/upload/cv/<?php echo $volunteer[0]['volunteer_cv'] ?>">Download</a>  </td>
                        </tr>
                        <tr>
                            <th valign="top">How I know about JA </th>
                            <td><?php echo $volunteer[0]['volunteer_reference'] ?></td>
                        </tr>
                    </table>
                    <br/><br/>
                    <h3>Contact Information</h3>
                    <br/>
                    <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                        <tr>
                            <th valign="top">My Email: </th>
                            <td><?php echo $volunteer[0]['volunteer_email'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Mobile Phone: </th>
                            <td><?php echo $volunteer[0]['volunteer_mobile'] ?></td>
                        </tr>
                        <tr>
                            <th valign="top">My Office Phone: </th>
                            <td><?php echo $volunteer[0]['volunteer_office'] ?></td>
                        </tr>
                    </table>
                    <br/><br/>
                    <h3>Preference Information</h3>
                    <br/>
                    <!-- print out volunteer details-->
                    <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                        <tr>
                            <th valign="top">My Preferred Educational Level: </th>
                            <td>
                                    <?php
                                    for ($i = 0; $i < count($education); $i++) {
                                        print " - ".$education[$i]['education_name']."<br/>";
                                    }
                                    ?>
                            </td>
                        </tr>
                        <tr>
                            <th valign="top">My Preferred Day:</th>
                            <td>
                                    <?php
                                    for ($i = 0; $i < count($time); $i++) {
                                        ?>
                                        <?php echo " - ".$time[$i]['time_name'].' <br/> ';
                                    }
                                    ?>
                            </td>
                        </tr>
                        <tr>
                            <th valign="top">My Preferred Location: <INPUT type="button" value="" class="form-help" onClick="window.open('../../include/singaporeArea.php','mywindow','width=520,height=340')"></th>
                            <td>
                                    <?php
                                    for ($i = 0; $i < count($location); $i++) {

                                        echo " - ".$location[$i]['location_name']." <br/> ";
                                    }
                                    ?>
                            </td>
                        </tr>

                    </table>
                    
                    <br/><br/>
                    <table>
                        <tr>
                            <td><input type='button'  value ="" onclick='history.go(-1)' class="form-back"/></td>
                            <td><input type='button' value="" onClick="window.location.href='volunteerUpdateAccount.php'" class="form-edit"/></td>
                        </tr>
                    </table>
                        <?php
                    }
                    ?>
                </div><!--RIGHT CONTENT BOX MIDDLE ENDS-->
                <div class="left-bottom"><!--RIGHT CONTENT BOX BOTTOM-->
                </div><!--RIGHT CONTENT BOX BOTTOM ENDS-->
            </div><!--RIGHT CONTENT ENDS-->
        </div><!--CONTAINER ENDS-->
        <div id="footer"><!--FOOTER STARTS-->
            <p>Copyright &copy; Junior Achievement Singapore | All Rights Reserved</p>
        </div><!--FOOTER ENDS-->
    </body>
</html>
